Do not pass static lib targets to rustc
authorCarl Lerche <me@carllerche.com>
Thu, 4 Sep 2014 00:36:41 +0000 (17:36 -0700)
committerCarl Lerche <me@carllerche.com>
Thu, 4 Sep 2014 00:36:41 +0000 (17:36 -0700)
src/cargo/ops/cargo_rustc/mod.rs
tests/test_cargo_compile.rs

index a4d1c60af2b2948804eb2ffd54a3c79c3e3e63ec..f9cb09631554ef291ec30159b0c17bc0ade51877 100644 (file)
@@ -405,6 +405,10 @@ fn build_deps_args(mut cmd: ProcessBuilder, target: &Target, package: &Package,
 
     if target.is_bin() {
         for target in targets {
+            if target.is_staticlib() {
+                continue;
+            }
+
             cmd = try!(link_to(cmd, target, cx, kind, LocalLib));
         }
     }
index ace545bc2eeff844ea02e5938236a94619f2c05c..9c754cc347e9365f0fd4bc50a0640f33b06aa68b 100644 (file)
@@ -1466,6 +1466,29 @@ test!(simple_staticlib {
     assert_that(p.cargo_process("build"), execs().with_status(0));
 })
 
+test!(staticlib_rlib_and_bin {
+    let p = project("foo")
+        .file("Cargo.toml", r#"
+              [package]
+              name = "foo"
+              authors = []
+              version = "0.0.1"
+
+              [lib]
+              name = "foo"
+              crate-type = ["staticlib", "rlib"]
+        "#)
+        .file("src/lib.rs", "pub fn foo() {}")
+        .file("src/main.rs", r#"
+              extern crate foo;
+
+              fn main() {
+                  foo::foo();
+              }"#);
+
+    assert_that(p.cargo_process("build"), execs().with_status(0));
+})
+
 test!(opt_out_of_lib {
     let p = project("foo")
         .file("Cargo.toml", r#"